package com.gw.vip.server.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gw.vip.server.po.TmpTransLock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

/**
 * @author GW
 * @description
 * @since 2022-05-07
 */
public interface TmpTransLockMapper extends BaseMapper<TmpTransLock> {
    /**
     * 清空表
     */
    @Update("TRUNCATE TABLE tmp_trans_lock")
    void truncate();

    /**
     * 初始化tmp_trans_acc_lock
     * @param clearDate
     * @return
     */
    @Insert("INSERT INTO tmp_trans_lock (SELECT * FROM trans_lock WHERE clear_date=#{clearDate})")
    Integer initData(LocalDate clearDate);

    /**
     * 初始化tmp_trans_acc_lock
     * @param clearDate
     */
    @Insert("INSERT INTO tmp_trans_lock (SELECT * FROM his_trans_lock WHERE clear_date=#{clearDate})")
    void initDataFromHis(LocalDate clearDate);

    /**
     * 根据清算日期查询
     * @param clearDate
     * @return
     */
    @Select("SELECT * FROM tmp_trans_lock WHERE clear_date=#{clearDate}")
    List<TmpTransLock> listByClearDate(LocalDate clearDate);
}
